home *** CD-ROM | disk | FTP | other *** search
- ;
- ; TED v1.0
- ; (Text Encryption Device)
- ;
- ; Written by Data Disruptor
- ; (c) 1991 The RABID International Development Corp.
- ;
-
- @print macro string
- mov ah,09h
- mov dx,offset string
- int 21h
- endm
-
- dosseg
- .model small
- .stack 100h
- .data
-
- ident db 13,10
- db "Text Encryption Device (TED) v1.0",13,10
- db "Written by Data Disruptor (Aug.16.91)",13,10,13,10
- db "(c) 1991 The RABID International Development Corp.",13,10,13,10
- db "Please enter text now",13,10
- db ">$"
-
-
-
- open_er db "Error opening file",13,10,"$"
-
- writ_er db "Error writing data",13,10,"$"
-
- clos_er db "Error closing file",13,10,"$"
-
- saved db "Encrypted text saved in ENCRYPT.TXT",13,10,"$"
-
- input db 80 dup (?) ; Set input buffer
-
- dest db 80 dup (?) ; Set a blank field to be
- ; the destination point for
- ; the encrypted string
- temp db 0 ; Tσmporary encrypted
- ; charachter buffer
- dol db "$",13,10 ; EOL so that we don't get
- ; a whole lot of crap on
- ; the screen
- crlf db 13,10,"$"
-
- counter db 0 ; For # of keypresses
-
- file db "encrypt.txt",0
- filehndl dw 0 ; Save the file handle
-
- .code
-
- start: mov ax,@data ; Read @DS into AX
- mov ds,ax ; Copy AX into DS
-
- @print ident
-
- mov si,offset input
- mov cx,1
- keyp:
- mov ah,01h ; Get keypress
- int 21h
- cmp al,13 ; Is it a CR?
- je exit_key ; Yes? Quit
- cmp al,8
- je dec_si
- mov [si],al ; No? Store the keypress
- inc cx
- inc si
- jmp keyp
-
- dec_si: dec si
- jmp keyp
-
- exit_key:
- @print crlf
- mov si,offset input ; Copy string into SI
- mov di,offset dest ; Copy target into DI
- encrypt:mov al,ds:[si] ; Copy first charachter
- ; in SI into AL
- mov temp,al ; Copy AL into TEMP
- xor byte ptr ds:[temp],1ah ; Encrypt TEMP with byte 01h
- mov al,temp ; Copy TEMP back into AL
- mov [di],al ; Move AL into DI
- inc si ; Increase counter [SI]
- inc di ; Increase counter [DI]
- loop encrypt ; Get the next byte in the
- ; string
- mov dx,offset dest ; copy encrypted string into DX
- call print ; INT 21h, func 09h
- jmp quit ; Quit the program
-
- print: mov ah,09h ; Procedure to output stσing
- int 21h ; in DX to the screen
- ret ; Return to where we were
- ; called from
-
- quit: mov dx,offset dol
- call print
- mov ah,3ch ; Create a file
- xor cx,cx ; Normal attributes
- mov dx,offset file ; Set the name of the file
- int 21h
- jc open_error
-
- mov word ptr [filehndl],ax ; Save the file handle
-
- mov ah,40h
- mov bx,word ptr [filehndl]
- mov cx,80
- mov dx,offset input
- int 21h
-
- mov ah,40h ; Write to file
- mov bx,word ptr [filehndl] ; Set file handle in BX
- mov cx,80
- mov dx,offset dest ; Set for text buffer
- int 21h
-
- jc write_error
-
- mov ah,3eh ; Close the file
- mov bx,word ptr [filehndl] ; ...in the file handle...
- int 21h
-
- jc close_error
-
- @print saved
- jmp bye
-
- open_error:
- @print open_er
- jmp error
- write_error:
- @print writ_er
- jmp error
- close_error:
- @print clos_er
- jmp error
-
- error: mov ah,0eh
- mov al,07 ; Beep!
- int 10h
-
- bye:
- mov ax,4c00h ; Terminate program with
- int 21h ; exit code 00
- end start ; Gedoudahere!
-